﻿//Mr Inventory by David Mauler 10.2.2010
//Mr Inventory is released under the 
//GNU General Public License version 2 (GPLv2)

using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Collections;

public partial class updateserv : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    public void onClick_bSearch(object sender, EventArgs e)
    {
        ArrayList servList = new ArrayList();
        ServerSql sqlFind = new ServerSql();
        servList = sqlFind.findByName(tbSerName.Text);

        ddServFnd.Items.Clear();

        if (servList == null)
        {
            lbMessage.Text = "<p class='evenLine'>No servers were found with that name</p>";
        }
        else
        {
            foreach (string server in servList)
            {
                ddServFnd.Items.Add(server);
            }       
        }

        bGetServ.Visible = true;
    }

    public void onClick_bGetServ(object sender, EventArgs e)
    {
        ServerSql sqlGetServ = new ServerSql();
        ServerInv serv = sqlGetServ.getByName(ddServFnd.SelectedValue.ToString());

        if (serv == null)
        {
            lbMessage.Text = "<p class='evenLine'>Error returning server</p>";
        }

        lbIdHolder.Text = serv.Id;
        tbName.Text = serv.Name;
        tbOs.Text = serv.Os;
        tbSoft.Text = serv.Software;
        tbVm.Text = serv.Vm;
        tbIp.Text = serv.Ip;
        tbModel.Text = serv.Model;
        tbSerNumb.Text = serv.Serial;
        tbCpu.Text = serv.Cpu;
        tbMem.Text = serv.Mem;
        tbStorage.Text = serv.Storage;
        tbLoc.Text = serv.Location;
        tbNotes.Text = serv.Notes;
    }

    public void onClick_bUpdate(object sender, EventArgs e)
    {
        ServerInv server = new ServerInv(tbName.Text, lbIdHolder.Text,tbOs.Text, tbSoft.Text, tbVm.Text,
                                         tbIp.Text, tbModel.Text, tbSerNumb.Text, tbCpu.Text,
                                         tbMem.Text, tbStorage.Text, tbLoc.Text, tbNotes.Text);

        ServerSql sqlUpdate = new ServerSql();
        lbMessage.Text = "<p class='evenLine'>" + sqlUpdate.updateServr(server) + "</p";
    }

           /* lbMessage.Text = "<p class='blackBoldNM'>Server Updated successfully</p>" +
                             "<p class='evenLine'>Server: " + tbName.Text + "</p>" +
                             "<p class='oddLine'>Location: " + tbLoc.Text + "</p>" +
                             "<p class='evenLine'>IP: " + tbIp.Text + "</p>" +
                             "<p class='oddLine'>OS: " + tbOs.Text + "</p>" +
                             "<p class='evenLine'>Software: " + tbSoft.Text + "</p>" +
                             "<p class='oddLine'>CPU: " + tbCpu.Text + "</p>" +
                             "<p class='evenLine'>MEM: " + tbMem.Text + "</p>" +
                             "<p class='oddLine'>Hardware: " + tbHard.Text + "</p>" +
                             "<p class='evenLine'>Serial # " + tbSerNumb.Text + "</p>" +
                             "<p class='oddLine'>VM: " + tbVM.Text + "</p>";            
        }*/

}

